package org.example.xiaomi.controller;



import org.example.xiaomi.dao.impl.CategoryServiceImpl;
import org.example.xiaomi.service.CategoryService;
import org.example.xiaomi.util.HttpResponseUtil;
import org.example.xiaomi.vo.ResultVO;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 删除业务
 */
@WebServlet("/category/del")
public class CategoryDelController extends HttpServlet {
    private CategoryService categoryService=new CategoryServiceImpl();
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //1 获取参数
        Long cid = Long.parseLong(req.getParameter("cid"));
        //2 业务
        int ret=categoryService.deleteCategory(cid);
        if(ret>0){
            HttpResponseUtil.response(resp, ResultVO.success(ret));
        }else {
            HttpResponseUtil.response(resp,ResultVO.fail("删除失败"));
        }

    }
}
